package com.zhouixi.task;

import com.zhouixi.listener.RocketListener;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * @author zr
 * @version 1.0
 * @date 2025/8/9
 */
@Slf4j
@Component
public class RocketScanTask {

    @Resource
    private Environment environment;

    @Resource
    private RocketListener rocketListener;


    @PostConstruct
    public void init() {
        log.info("======RocketScanTask init=======");
        RocketMQMessageListener annotation = rocketListener.getClass().getAnnotation(RocketMQMessageListener.class);
        String topic = environment.resolvePlaceholders(annotation.topic());
        String consumerGp = environment.resolvePlaceholders(annotation.consumerGroup());
        String tag = environment.resolvePlaceholders(annotation.selectorExpression());
        log.info("RocketScanTask topic: {}", topic);
        log.info("RocketScanTask consumerGp: {}", consumerGp);
        log.info("RocketScanTask tag: {}", tag);
        log.info("======RocketScanTask init=======");
    }
}
